/*
enum:枚举/匹配 验证
只有使用在String类型的字段上
*/


const mongoose=require('mongoose');
mongoose.Promise=global.Promise;
mongoose.connect('mongodb://localhost:27017/test',{useMongoClient:true});


const Enum=mongoose.model('Enum',new mongoose.Schema({
    desc:String,
    str:{
        type:String,
        enum:['a','b']
    },
    tags:{
        type:Array,
        enum:['A','B']
    }
}));

new Enum({str:'c',tags:['C','D']}).save((err,ret)=>{
    console.log('save:',err,ret);
});